package com.moyun.common.event;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * <h3>moyun-base</h3>
 * <p>创建事件源</p>
 *
 * @author : ybx
 * @date : 2022-04-23 15:04:30
 **/
@Slf4j
@Component
@RequiredArgsConstructor
public class MessageEventPublisher {
    private final ApplicationEventPublisher applicationEventPublisher;

    public void publishMessageEvent(String message) {
        log.info("发布了一个事件消息{}", message);
        applicationEventPublisher.publishEvent(new MessageEvent(this, message));
    }
}
